export const API_BASE = "/dev-api"

export function mockGetSuccess(url, data = {}) {
    return mockRequest(url, "get", {
        code: 200,
        message: "请求成功",
        success: true,
        data: data
    })
}

export function mockGetError(url, data = {}) {
    return mockRequest(url, "get", {
        code: 500,
        message: "请求失败",
        success: true,
        data: data
    })
}

export function mockPostSuccess(url, data = {}) {
    return mockRequest(url, "post", {
        code: 200,
        message: "请求成功",
        success: true,
        data: data
    })
}

export function mockPostError(url, data = {}) {
    return mockRequest(url, "post", {
        code: 500,
        message: "请求失败",
        success: true,
        data: data
    })
}

export function mockRequest(url, method, data = {}) {
    return {
        url: API_BASE + url,
        method: method,
        response: () => {
            return data;
        }
    }
}

